import Vue from 'vue'
import VueRouter from 'vue-router'

// 一级路由
import Layout from '@/views/LayOut'
import Register from '@/views/register'
import Login from '@/views/login'
import MyCollection from '@/views/LayOut/three-route/my-collection.vue'
import MyRental from '@/views/LayOut/three-route/my-rental.vue'

// 二级路由
import LookRoom from '@/views/LayOut/second-route/look-room.vue'
import MyInformation from '@/views/LayOut/second-route/my-information.vue'
import MyHome from '@/views/LayOut/second-route/my-home.vue'
import MyUser from '@/views/LayOut/second-route/my-user.vue'

Vue.use(VueRouter)

const routes = [
  // 一级路由
  {
    // 我的出租
    path: '/rental',
    component: MyRental
  },
  {
    // 我的收藏
    path: '/collection',
    component: MyCollection
  },
  {
    path: '/register',
    component: Register
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: '/user',
        component: MyUser
      },
      {
        path: '/home',
        component: MyHome
      },
      {
        path: '/look',
        component: LookRoom
      },
      {
        path: '/infor',
        component: MyInformation
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
